package com.aqie.advanced.springApplication.bootstrap;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.HashSet;
import java.util.Set;

@Slf4j
public class SpringApplicationBootstrap {
    public static void main(String[] args) {
        // 也可以在启动类添加注解; 可以添加任意配置bean,不一定要主类
        // SpringApplication.run(ApplicationConfiguration.class,args);

        Set<String> sources = new HashSet<>();
        sources.add(ApplicationConfiguration.class.getName());
        SpringApplication springApplication = new SpringApplication();
        springApplication.setSources(sources);
        // 配置当前web类型
        // springApplication.setWebApplicationType(WebApplicationType.NONE);
        ConfigurableApplicationContext run = springApplication.run(args);
        log.info("bean : {}",run.getBean(ApplicationConfiguration.class));
    }

    @SpringBootApplication
    public static class ApplicationConfiguration{}
}
